package cn.tedu.controller;

import cn.tedu.pojo.Car;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :Colin
 * @version 创建时间: 2021/7/14 9:52
 */
@RestController//@Controller+@ResponseBody
@RequestMapping("car")
public class CarController {
    @RequestMapping("get")
    public String get(){
        return "00123";
    }
    @RequestMapping("get2")
    public Car get2(){
       Car car = new Car(711,"colin","cayman","red",618.96);
//        car.setColor("红色");
//        car.setId(11);
//        car.setName("niubility");
//        car.setPrice(119.12);
        //含参构造也可以在创建对象时赋值。但必须是后端自己写代码属性赋值
        //如果前端给属性传递值，就必须get，set方法，否则会出现报错
        // There was an unexpected error (type=Not Acceptable, status=406).

        return car;
    }
    @RequestMapping("add")
    public String add(int id, String name){
        System.out.println(id+name);
        return id+name;
    }
    @RequestMapping("add2")
    public Car add2(Car car){
        System.out.println(car);
        return car;
    }
}
